<?php namespace App\Core\Repository\Criterias;

use App\Core\Repository\Criteria;
use App\Core\Repository\Repository;

class FixedCriteria extends Criteria {
    
    protected $field;
    protected $value;

    public function __construct($field, $value) {
        $this->field = $field;
        $this->value = $value;
        $this->setName('fixed_'.$this->field);
    }

    public function apply(Repository $repository){
        parent::apply($repository);
        $this->query->where($this->formatField($this->model, $this->field), '=', $this->value);
    }
}